{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">
                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="order_user_name" class="layui-input search" name="order_user_name" value="" placeholder="收货人"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline">
                            <input type="text" id="order_user_phone" class="layui-input search" name="order_user_phone" value="" placeholder="手机号"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" >
                            <input type="text" id="order_number" class="layui-input search" name="order_number" value="" placeholder="订单号"/>
                        </div>

                        <div class="layui-input-inline layui-form">
                            <select name="order_status" id="order_status" lay-search="" class="layui-input">
                                <option  value="">不限状态</option>
                                <option  value="1">待付款</option>
                                <option  value="2">待发货</option>
                                <option  value="3">待收货</option>
                                <option  value="4">已完成</option>
                                <option  value="5">已关闭</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" >
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <!--<button class="btn btn-primary" type="button" onclick="wk.href('{:url('goodsAdd')}');">-->
                            <!--<i class="fa fa-plus"></i> 添加商品-->
                        <!--</button>-->

                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                        <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                        <!--<li><a href="javascript:;" class="layuiBtn" data-type="getCheckData"><i class="fa fa-trash-o"></i> 批量删除 </a></li>-->
                        <li><a  href="javascript:;" class="layuiBtn" data-type="batchClose"><i class="fa fa-check-circle"></i> 批量关闭订单</a></li>
                        <li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-ban"></i> 批量删除订单</a></li>
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>
                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--图片模板-->
                    <!--<script type="text/html" id="imgTpl">-->
                    <!--<img src="{{d.goods_thumb}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />-->
                    <!--</script>-->
                    <!--操作模板-->
                    <!--<script type="text/html" id="pay">-->
                        <!--{{# if(d.order_pay_type == 1){ }}-->
                        <!--支付宝-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_pay_type == 2){ }}-->
                        <!--微信-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_pay_type == 3){ }}-->
                        <!--余额-->
                        <!--{{# } }}-->
                    <!--</script>-->

                    <!--<script type="text/html" id="stat">-->
                        <!--{{# if(d.order_status == 1){ }}-->
                        <!--待付款-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_status == 2){ }}-->
                        <!--待发货-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_status == 3){ }}-->
                        <!--待收货-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_status == 4){ }}-->
                        <!--已完成-->
                        <!--{{# } }}-->
                        <!--{{# if(d.order_status == 5){ }}-->
                        <!--已关闭-->
                        <!--{{# } }}-->
                    <!--</script>-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('orderDetail')}?order_id={{d.order_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                        {{# if(d.order_status == 2){ }}
                        <a href="javascript:;" onclick="wk.href('{:url('orderSend')}?order_id={{d.order_id}}')" class="btn btn-primary btn-xs m-r-xs" title="发货">发货</a>
                        {{# } }}
                        {{# if(d.order_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.order_id}}','{:url('orderClose')}','确定关闭订单吗?')" class="btn btn-danger btn-xs m-r-xs" title="关闭">关闭</a>
                        {{# } }}
                        {{# if(d.order_status == 4 || d.order_status == 5){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.order_id}}','{:url('orderDel')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        {{# } }}
                        {{# if(d.order_status == 3){ }}
                        <a href="javascript:;" onclick="wk.layer_show('物流', '{:url('orderWuLiu')}?order_id={{d.order_id}}')" class="btn btn-primary btn-xs m-r-xs" title="物流">物流</a>
                        <a href="javascript:;" onclick="wk.href('{:url('updateWuLiu')}?order_id={{d.order_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑物流">编辑物流</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<textarea id="allidsForOut" class="hidden"></textarea>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Order/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                  {type: 'checkbox', fixed: 'left',}
                , {field: 'order_number', width: 190, title: '订单号', align: 'center'}
                , {field: 'status_name', width: 100, title: '状态', align: 'center'}
                , {field: 'order_user_name', width: 120, title: '收货人', align: 'center'}
                , {field: 'order_user_phone', width: 120, title: '手机号', align: 'center'}
                , {field: 'address', width: 120, title: '收货地址', align: 'center'}
                , {field: 'order_time', width: 160, title: '下单时间', align: 'center'}
                , {field: 'order_num', width: 90, title: '购买数量', align: 'center'}
                , {field: 'goods_name', width: 160, title: '商品名称', align: 'center'}
                , {field: 'order_price', width: 140, title: '订单金额', align: 'center'}
                , {field: 'pay_type_name', width: 100, title: '支付方式', align: 'center'}
                , {field: 'order_expressage_num', width: 140, title: '物流单号', align: 'center'}
//                , {field: 'order_pay_type', width: 90, title: '支付方式', align: 'center',toolbar: '#pay'}
//                , {field: 'order_status', width: 90, title: '状态', align: 'center',toolbar: '#stat'}
                , {fixed: 'right', width:200, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('#allidsForOut').val(res.count2);
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量关闭订单
            batchClose:function () {
                wk.batchClose(getIds(),"{:url('batchClose')}");
            },
            //批量删除订单
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('batchDel')}");
            },
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect($('#allidsForOut').val(),$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['order_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>